package com.ecommerce.order.entity;

import com.ecommerce.common.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "orders")
public class Order extends BaseEntity {

    /**
     * 订单编号
     */
    @Column(unique = true, nullable = false, length = 50)
    private String orderNo;

    /**
     * 用户ID
     */
    @Column(nullable = false)
    private Long userId;

    /**
     * 用户名
     */
    @Column(nullable = false, length = 100)
    private String username;

    /**
     * 订单总金额
     */
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal totalAmount;

    /**
     * 运费
     */
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal shippingFee;

    /**
     * 实付金额
     */
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal payAmount;

    /**
     * 订单状态：0-待付款，1-待发货，2-已发货，3-已完成，4-已取消，5-退款中，6-已退款
     */
    @Column(nullable = false)
    private Integer status;

    /**
     * 支付方式：1-微信支付，2-支付宝，3-银行卡
     */
    private Integer paymentMethod;

    /**
     * 支付时间
     */
    private LocalDateTime paymentTime;

    /**
     * 发货时间
     */
    private LocalDateTime shippingTime;

    /**
     * 完成时间
     */
    private LocalDateTime completionTime;

    /**
     * 收货人姓名
     */
    @Column(nullable = false, length = 50)
    private String receiverName;

    /**
     * 收货人手机号
     */
    @Column(nullable = false, length = 20)
    private String receiverPhone;

    /**
     * 收货地址
     */
    @Column(nullable = false, length = 200)
    private String receiverAddress;

    /**
     * 备注
     */
    @Column(length = 500)
    private String remark;
}